#!/usr/bin/python

###############################
## A base function for plots ##
###############################

#######################################################      
## Set PyRoot Environment and PlotConfig Path first ###
#######################################################
import sys
ROOTSYS = '/afs/atlas.umich.edu/opt/root/lib'
sys.path.append(ROOTSYS)
PlotConfig='../'
PlotConfig2='.'
sys.path.append(PlotConfig)
sys.path.append(PlotConfig2)

#####################
## Import Module  ###
#####################
import array
import os
import glob
from math import sqrt,fabs,sin
from ROOT import TFile,TTree,TChain,TBranch,TH1,TH1F,TList
from ROOT import TLorentzVector
from ROOT import THStack,TCanvas,TLegend,TColor,TPaveText
from ROOT import gStyle,gDirectory

####################
## Import Template #
####################
from plot_template import plot_template
from plot_template_separate import plot_template_separate
from plot_template_combined import plot_template_combined

###############
## Plotting ###
###############
RatioSize=0.2
RatioErr=1
RatioMin,RatioMax=0.5,1.5
RatioAdj=-1

### Pt, dPhi ranges
PtllMin, PtllMax =  20, 200
dPhiMin, dPhiMax = -0.5, 4
### Rebinning
##  Cut2gl
Cut2gl_NRePtll_ll, Cut2gl_NRePtll_em = 5, 5
Cut2gl_NRedPhi_ll, Cut2gl_NRedPhi_em = 5, 5
##  CutMll
CutMll_NRePtll_ll, CutMll_NRePtll_em = 5, 5
CutMll_NRedPhi_ll, CutMll_NRedPhi_em = 5, 5
##  CutMzWindow
CutMzWindow_NRePtll_ll, CutMzWindow_NRePtll_em = 2, 2
CutMzWindow_NRedPhi_ll, CutMzWindow_NRedPhi_em = 1, 1
##  CutMETAx
CutMETAx_NRePtll_ll, CutMETAx_NRePtll_em = 5, 5
CutMETAx_NRedPhi_ll, CutMETAx_NRedPhi_em = 5, 5
##  CutJetVeto
CutJetVeto_NRePtll_ll, CutJetVeto_NRePtll_em = 5, 5
CutJetVeto_NRedPhi_ll, CutJetVeto_NRedPhi_em = 5, 5
##  CutFracDiff
CutFracDiff_NRePtll_ll, CutFracDiff_NRePtll_em = 5, 5
CutFracDiff_NRedPhi_ll, CutFracDiff_NRedPhi_em = 5, 5

ATLAS='ATLAS Preliminary'
figFormat='png'
Rebin=1
Events=str('Events / %dGeV' % Rebin)
plot_template_separate(hname='CutMzWindow_Pt1_ee',hxt='leading electron pt, ee',hyt=Events,hrebin=CutMzWindow_NRePtll_ll,xmin=PtllMin,xmax=PtllMax,ratio=RatioSize,ratio_min=RatioMin,ratio_max=RatioMax,ratio_adj=RatioAdj,ratio_err=RatioErr,showATLAS=ATLAS,figformat=figFormat)
plot_template_separate(hname='CutMzWindow_Pt1_mm',hxt='leading muon pt, mm',hyt=Events,hrebin=CutMzWindow_NRePtll_ll,xmin=PtllMin,xmax=PtllMax,ratio=RatioSize,ratio_min=RatioMin,ratio_max=RatioMax,ratio_adj=RatioAdj,ratio_err=RatioErr,showATLAS=ATLAS,figformat=figFormat)

